//
//  DDNewsController.m
//  NetEaseNews
//
//  Created by dqw on 15/7/24.
//  Copyright (c) 2015年 itcast. All rights reserved.
//

#import "DDNewsController.h"
#import "DDNews.h"
#import "DDNewsCell.h"
@interface DDNewsController ()
@property (strong, nonatomic) IBOutlet UITableView *headlineView;
@property (strong, nonatomic) NSArray *newsList;

@end


@implementation DDNewsController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [DDNews newsListWithUrlStr:self.urlStr completionB:^(NSArray *arr) {
        self.newsList = arr;
    }];
}
- (void)setNewsList:(NSArray *)newsList
{
    _newsList = newsList;
    [self.tableView reloadData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.newsList.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    DDNews *news = self.newsList[indexPath.row];
    DDNewsCell *cell = [tableView dequeueReusableCellWithIdentifier:[DDNewsCell reuseIDWithNews:news]];
    cell.news = self.newsList[indexPath.row];
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [DDNewsCell rowHeightWithNews:self.newsList[indexPath.row]];
}

@end
